<template>
	<view>
		<!-- <view class="grid-box u-m-0">
			<view class="u-text-left">
				<view class="u-m-t-20 u-m-b-20">
					<view><text class="u-font-32">{{operatorName}}</text></view>
					<text class="u-tips-color">运营商可支配余额（元）</text>
					<u-button type="primary" size="mini" @click="goView('/pages/admin/recharge/recharge')">充值</u-button>
					<u-button type="warning" size="mini" plain class="u-m-l-30" @click="goView('/pages/shop/my/balance/balance')">明细</u-button>
				</view>
				<view>
					<text class="u-font-24">￥</text>
					<text class="balance bold u-font-60" v-if="showBalance">{{utils.formatMoney(balance)}}</text>
					<text class="balance bold u-font-60" v-else>****</text>
				</view>
				<view>
					
				</view>
			</view>
		</view> -->
		<view class="">
			<view class="u-p-l-30 u-p-t-30 u-p-b-10">
				<text class="u-font-24">运营商管理</text>
			</view>
			<u-cell-group>
				<!-- <u-cell-item title="查看余额记录" @click="goView('/pages/shop/my/balance/balance')"></u-cell-item> -->
				<u-cell-item title="管理员设置" @click="goView('/pages/admin/staff/staff')"></u-cell-item>
				<u-cell-item title="加盟商管理" @click="goView('/pages/admin/franchise/franchise')"></u-cell-item>
				<!-- <u-cell-item title="加盟商充值审核" @click="goView('/pages/admin/franchise/charge/charge')"></u-cell-item> -->
				<!-- <u-cell-item title="站点管理" @click="goView('/pages/admin/store/store')"></u-cell-item> -->
			</u-cell-group>
		</view>
		<view class="">
			<view class="u-p-l-30 u-p-t-30 u-p-b-10">
				<text class="u-font-24">可回收物管理</text>
			</view>
			<u-cell-group>
				<u-cell-item title="类型设置" @click="goView('/pages/admin/catalogue/catalogue')"></u-cell-item>
				<u-cell-item title="可回收物设置" @click="goView('/pages/admin/productList/productList')"></u-cell-item>
				<u-cell-item title="价格表" @click="goView('/pages/admin/priceTable/priceTable')"></u-cell-item>
			</u-cell-group>
		</view>
		
		<!-- 底部菜单 -->
		<tabbar :current="1"></tabbar>
	</view>
</template>

<script>
	import tabbar from '../components/tabbar/tabbar.vue'
	import {
		mapState
	} from 'vuex';
	
	export default {
		components:{
			tabbar
		},
		data() {
			return {
				balance: 0,
				showBalance: true, // 添加控制余额显示的变量，默认显示
				operatorName: ''
			}
		},
		computed: {
			...mapState({
				userdetail: state => state.userdetail,
				storeId: state => state.storeId,
				franchiseId: state => state.franchiseId,
				operatorId: state => state.operatorid
			}),
			photo() {
				return this.fileURL + this.userdetail.photo
			},
			// 是否运营商管理员
			isOperatorAdmin(){
				return this.userdetail.bindinfo.operator.ismanager
			},
			// 是否加盟商管理员
			// isFranchiseAdmin(){
			// 	return this.userdetail.bindinfo.operator.franchiselist.find((item)=>item.id == this.franchiseId).ismanager
			// },
			// 是否（当前）站点的管理员
			// isStoreAdmin(){
			// 	if(this.storeId > 0){
			// 		return this.userdetail.bindinfo.operator.franchiselist.find((item)=>item.id == this.franchiseId).storelist.find((item)=>item.id == this.storeId).ismanager
			// 	}else{
			// 		return false
			// 	}
			// }
		},
		onShow() {
			this.operatorDetails()
		},
		methods: {
			goView(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 添加切换余额显示的方法
			toggleBalance() {
				this.showBalance = !this.showBalance;
			},
			operatorDetails(){
				return this.$u.get('/Operator/Detail?id='+this.operatorid).then((res)=>{
					console.log('operatorDetails',res)
					this.balance = res.balance
					this.operatorName = res.name
				})
			},
			franchiseDetails(){
				return this.$u.get('/Franchise/Detail?id='+this.franchiseId).then((res)=>{
					console.log('franchiseDetails',res)
					if(res.enablebalance){
						this.balance = res.balance
					}else{
						this.operatorDetails()
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.grid-box{
		border-radius: 0;
	}
	.links{
		color: $u-color-blue;
		border-bottom: 1px solid $u-color-blue;
	}
</style>
